//
//  WFBaseUIView.m
//  谷居
//
//  Created by dllo on 16/6/16.
//  Copyright © 2016年 刘万方. All rights reserved.
//

#import "WFBaseUIView.h"

@implementation WFBaseUIView
//- (instancetype)init {
//    self = [super init];
//    if (self) {
//        [self setColor];
//        
//        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeToNight:) name:@"夜间模式" object:nil];
//        NSLog(@"UIView初始化.");
//
//    }
//    return self;
//}
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self setColor];

        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeToNight:) name:@"夜间模式" object:nil];
    }
    return self;
}



- (void)setColor {
    if (![[NSUserDefaults standardUserDefaults] integerForKey:@"夜间模式"]) {
        self.backgroundColor = DAY_COLOR;
    } else {
        self.backgroundColor = NIGHT_COLOR;
    }
}
-(void)changeToNight:(NSNotification *)sender {
    if (![[NSUserDefaults standardUserDefaults] integerForKey:@"夜间模式"]) {
        self.backgroundColor = NIGHT_COLOR;
    } else {
        self.backgroundColor = DAY_COLOR;
    }
}

- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    NSLog(@"移除通知中心");
    [super dealloc];
}

@end
